﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            LoadLoaiSanPham();
            LoadSanPhamMoi(); MasterPage master = (MasterPage)this.Master;
            LoadDoiTac();
            LoadHotrotructuyen();
        }
    }

    private void LoadLoaiSanPham()
    {
        repLoaiSanPham.DataSource = new LoaiSanPhamHelper().LoadLoaiSanPhamGoc();
        repLoaiSanPham.DataBind();
    }

    protected void repLoaiSanPham_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            LoaiSanPhamHelper lspHP = new LoaiSanPhamHelper();
            Repeater repCon = ((Repeater)e.Item.FindControl("repLoaiSanPhamCon"));
            repCon.DataSource = (lspHP.LoadLoaiSanPhamCon(Convert.ToInt32((((DataRowView)e.Item.DataItem)["LoaiSanPhamID"]))));
            repCon.DataBind();
        }
    }

    private void LoadSanPhamMoi()
    {
        repSanPhamMoi.DataSource = new SanPhamHelper().LoadSanPhamMoi();
        repSanPhamMoi.DataBind();
    }
    private void LoadDoiTac()
    {
        DoiTacDataSet bnDS = new DoiTacHelper().LoadDoiTac();
        repDoiTac.DataSource = bnDS;
        repDoiTac.DataBind();
    }

    private void LoadHotrotructuyen()
    {
        dllOnline.DataSource = new HoTroTrucTuyenHelper().LoadHoTroTrucTuyen();
        dllOnline.DataBind();
    }

}
